package com.intelligencesoft.pss.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javax.servlet.ServletContext;

public class PropertiesUtil {
	private static final String PROPERTIESURL="WEB-INF/classes/auth_filter.properties";
	private static final String AUTHURL="rtsAuth";
	private static final String EXCLUDESURL="auth.excludes.url";
	
	public static Properties getProperties(ServletContext context) {
		Properties ps = new Properties();
		 InputStream in = context.getResourceAsStream(PROPERTIESURL);
		 try {
			ps.load(in);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return ps; 
	}
	
	public static String getAuthUrl(Properties ps) {
		String rtsAuth="";
		if (null!=ps.get(AUTHURL)&&!"".equals(ps.get(AUTHURL))) {
			rtsAuth=(String) ps.get(AUTHURL);
		}
		return rtsAuth;
	}
	
	public static String[] getExcludesUrl(Properties ps) {
		String[] excludes=null;
		if (null!=ps.get(EXCLUDESURL)&&!"".equals(ps.get(EXCLUDESURL))) {
			excludes = ((String) ps.get(EXCLUDESURL)).split(",");
		}
		return excludes;
	}
}
